package com.scribbles.common.entity;

// Generated 15-Jul-2011 16:47:57 by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

import org.codehaus.jackson.annotate.JsonAutoDetect;

/**
 * Article generated by hbm2java
 */
@Entity
@Table(name = "article", catalog = "ksharedb")
@JsonAutoDetect
@NamedQueries({
		@NamedQuery(name = "retrieveArticlesForUserId", query = "select a from Article a where a.createdBy.userId = :userId"),
		@NamedQuery(name="getArticlesListForHeader", query="select a.id, a.name from Article a where a.articleHeader.id = :articleHeaderId") })
public class Article implements java.io.Serializable {

	private Integer id;
	private Integer version;
	private ArticleHeader articleHeader;
	private String name;
	private String description;
	private String articleContent;
	private AppUser createdBy;
	private AppUser updatedBy;
	private Date createdDate;
	private Date updatedDate;

	public Article() {
	}

	public Article(ArticleCategory articleCategory, String name,
			String description, String articleContent, AppUser createdBy,
			AppUser updatedBy, Date createdDate, Date updatedDate) {
		this.name = name;
		this.description = description;
		this.articleContent = articleContent;
		this.createdBy = createdBy;
		this.updatedBy = updatedBy;
		this.createdDate = createdDate;
		this.updatedDate = updatedDate;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Version
	@Column(name = "VERSION")
	public Integer getVersion() {
		return this.version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	@Column(name = "NAME", length = 60)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "DESCRIPTION", length = 200)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "ARTICLE_CONTENT")
	public String getArticleContent() {
		return this.articleContent;
	}

	public void setArticleContent(String articleContent) {
		this.articleContent = articleContent;
	}

	@OneToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "CREATED_BY")
	public AppUser getCreatedBy() {
		return this.createdBy;
	}

	public void setCreatedBy(AppUser createdBy) {
		this.createdBy = createdBy;
	}

	@OneToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "UPDATED_BY")
	public AppUser getUpdatedBy() {
		return this.updatedBy;
	}

	public void setUpdatedBy(AppUser updatedBy) {
		this.updatedBy = updatedBy;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CREATED_DATE", length = 19)
	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "UPDATED_DATE", length = 19)
	public Date getUpdatedDate() {
		return this.updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}

	@ManyToOne
	@JoinColumn(name = "ARTICLE_HEADER_ID")
	public ArticleHeader getArticleHeader() {
		return articleHeader;
	}

	public void setArticleHeader(ArticleHeader articleHeader) {
		this.articleHeader = articleHeader;
	}

	@Override
	public String toString() {
		return "Article [id=" + id + ", version=" + version + ", name=" + name
				+ ", description=" + description + ", articleContent="
				+ articleContent + ", createdBy=" + createdBy + ", updatedBy="
				+ updatedBy + ", createdDate=" + createdDate + ", updatedDate="
				+ updatedDate + "]";
	}

}
